package com.ruoyi.zcxt.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zcxt.domain.ZcCgzzxs;
import com.ruoyi.zcxt.service.IZcCgzzxsService;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 资产采购组织形式Controller
 * 
 * @author fish
 * @date 2024-01-12
 */
@RestController
@RequestMapping("/zcxt/cgzzxs")
public class ZcCgzzxsController extends BaseController
{
    @Autowired
    private IZcCgzzxsService zcCgzzxsService;

    /**
     * 查询资产采购组织形式列表
     */
    @PreAuthorize("@ss.hasPermi('zcxt:cgzzxs:list')")
    @GetMapping("/list")
    public AjaxResult list(ZcCgzzxs zcCgzzxs)
    {
        List<ZcCgzzxs> list = zcCgzzxsService.selectZcCgzzxsList(zcCgzzxs);
        return success(list);
    }

    /**
     * 导出资产采购组织形式列表
     */
    @PreAuthorize("@ss.hasPermi('zcxt:cgzzxs:export')")
    @Log(title = "资产采购组织形式", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZcCgzzxs zcCgzzxs)
    {
        List<ZcCgzzxs> list = zcCgzzxsService.selectZcCgzzxsList(zcCgzzxs);
        ExcelUtil<ZcCgzzxs> util = new ExcelUtil<ZcCgzzxs>(ZcCgzzxs.class);
        util.exportExcel(response, list, "资产采购组织形式数据");
    }

    /**
     * 获取资产采购组织形式详细信息
     */
    @PreAuthorize("@ss.hasPermi('zcxt:cgzzxs:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zcCgzzxsService.selectZcCgzzxsById(id));
    }

    /**
     * 新增资产采购组织形式
     */
    @PreAuthorize("@ss.hasPermi('zcxt:cgzzxs:add')")
    @Log(title = "资产采购组织形式", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZcCgzzxs zcCgzzxs)
    {
        return toAjax(zcCgzzxsService.insertZcCgzzxs(zcCgzzxs));
    }

    /**
     * 修改资产采购组织形式
     */
    @PreAuthorize("@ss.hasPermi('zcxt:cgzzxs:edit')")
    @Log(title = "资产采购组织形式", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZcCgzzxs zcCgzzxs)
    {
        return toAjax(zcCgzzxsService.updateZcCgzzxs(zcCgzzxs));
    }

    /**
     * 删除资产采购组织形式
     */
    @PreAuthorize("@ss.hasPermi('zcxt:cgzzxs:remove')")
    @Log(title = "资产采购组织形式", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zcCgzzxsService.deleteZcCgzzxsByIds(ids));
    }
}
